package com.clayecloud.common.admin.controller;

import com.clayecloud.common.admin.services.HouseOrderService;
import com.clayecloud.common.entity.HouseOrder;
import com.clayecloud.common.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/house/order")
@Api(tags = "住户相关账单")
public class AdminHouseOrderController {

    @Resource
    private HouseOrderService houseOrderService;

    @PostMapping("/insert")
    @ApiOperation("增加账单")
    public MessageUtil insertHouseOrder(HouseOrder houseOrder){
        return houseOrderService.insertSelective(houseOrder);
    }

    @GetMapping("/delete")
    @ApiOperation("删除账单根据订单id")
    public MessageUtil deleteHouseOrderByID(Integer orderId){
        return houseOrderService.deleteByPrimaryKey(orderId);
    }

    @PutMapping("/update")
    @ApiOperation("更新房屋账单")
    public MessageUtil updateHouseOrder(HouseOrder houseOrder){
        return houseOrderService.updateByPrimaryKeySelective(houseOrder);
    }

    @GetMapping("/selectAll")
    @ApiOperation("查询所有账单")
    public MessageUtil selectAllHouseOrder(Integer size, Integer page){
        return houseOrderService.selectAll(size, page);
    }

    @GetMapping("/selectAll/0")
    @ApiOperation("查询所有未缴费账单")
    public MessageUtil selectAllByOrderStateNoFinish(Integer size, Integer page){
        return houseOrderService.selectAllByOrderState(size, page, 0);
    }

    @GetMapping("/selectAll/1")
    @ApiOperation("查询所有缴费账单")
    public MessageUtil selectAllHouseOrderFinish(Integer size, Integer page){
        return houseOrderService.selectAllByOrderState(size, page, 1);
    }

}
